-
Notifications
You must be signed in to change notification settings - Fork 66
WIP: TypeScript typings #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I am not a TypeScript expert but this works for me. Please let me know what you think and thanks for this very useful extension :) |
To try out these typings in your project, you can temporarily add
instead of vue-async-computed. |
I copied your index.d.ts into my project, and asyncComputed property warning is solved. But if I call an asyncComputed method from anywhere says: |
@trollderius, you are right, that part is still missing. Let me see if I can get that to work as well. |
My workaround here is using an 'any' interface, but the sad thing is all types correlations are lost.
|
I think it's quite hard to get the typings completely right here. You'd have to augment constructions like this one basically:
I.e., add a new generic parameter So I was wondering, why is This seems to work and I pushed a proof-of-concept to this PR. (We should of course not replace all the old tests, I just wanted to see that this actually works and that typescript was happy with the tests now.) |
this is a proof of concept that asyncComputed can be merged into computed and the distinction between a normal computed and an async-computed can be made by an extra keyword. The upside of this is that it fixes typings as we can rely on the standard typings that come with Vue.js' computed properties.
@foxbenjaminfox is there a strong reason why vue-async-computed could not support computed properties with |
I am not sure whether it's possible to get the types right. My most promising attempt so far was
With this I can set a computed's
and TypeScript knows that I got this to work mostly (strangely it does not work in
However decorators in TypeScript can not modify the return type yet, so this did not work. |
So, I am not satisfied with the current state of this and I don't have more time to invest here. |
this is a hack and it does not fully work unfortunately. I simplified the code for this to drop the distinction of lazy/non-lazy props.
resolves #25